package com.example.shopping2.a_c_fragment.home.adapter

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.example.shopping2.R
import com.example.shopping2.a_c_fragment.home.entity.Recommend_Entity
import com.youth.banner.adapter.BannerAdapter
import com.youth.banner.util.BannerUtils

class Recommend_Adapter :BannerAdapter<Recommend_Entity,Recommend_Adapter.RecomHolder> {
    private var context:Context ? = null
    constructor(list:ArrayList<Recommend_Entity>,context:Context):super(list){
        this.context = context
    }


    override fun onCreateHolder(parent: ViewGroup, viewType: Int): RecomHolder {
        return RecomHolder(BannerUtils.getView(parent,R.layout.recommend))
    }

    override fun onBindView(
        holder: RecomHolder,
        data: Recommend_Entity,
        position: Int,
        size: Int
    ) {
        Glide.with(context).load(data.url).into(holder.image)
    }
    class RecomHolder:RecyclerView.ViewHolder{
        var image:ImageView? = null
        constructor(itemview:View):super(itemview){
            image = itemview.findViewById(R.id.recom_img)
        }
    }


}